//
//  FJC_AVswipeCardCell.m
//  滴滴快拍
//
//  Created by dllo on 16/5/19.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "FJC_AVswipeCardCell.h"
#import "Frame.h"

@interface FJC_AVswipeCardCell ()



@end

@implementation FJC_AVswipeCardCell

- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
        [self setupSubViews];
    }
    return self;
}


- (void)setupSubViews {
    
    self.VideoView = [FJC_VideoView new];
    self.VideoView.backgroundColor = [UIColor redColor];
    [self addSubview:self.VideoView];
    
    self.picImageView = [BaseImageView new];
    self.picImageView.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.picImageView];
    
    self.playButton = [BaseButton buttonWithType:UIButtonTypeCustom];
    [self addSubview:self.playButton];
    
    self.headImageView = [BaseImageView new];
    self.headImageView.backgroundColor = [UIColor redColor];
    [self addSubview:self.headImageView];
    
    self.nameTitleLabel = [BaseLabel new];
    self.nameTitleLabel.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.nameTitleLabel];
    
    self.briefTitleLabel = [BaseLabel new];
    self.briefTitleLabel.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.briefTitleLabel];
    
    self.hotLabel = [BaseLabel new];
    self.hotLabel.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.hotLabel];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.picImageView.frame = CGRectMake(0, 0, VIEW_WIDTH, VIEW_WIDTH * 7 / 6);
    
    self.VideoView.frame = CGRectMake(0, 0, VIEW_WIDTH, VIEW_WIDTH * 7 / 6);
    self.VideoView.tag = 1000;
    self.playButton.frame = CGRectMake(VIEW_WIDTH / 2 - 30, VIEW_WIDTH * 5 / 8 - 30, 60, 60);
    self.playButton.layer.cornerRadius = 30;
    self.playButton.layer.masksToBounds = YES;
    [self.playButton setImage:[UIImage imageNamed:@"play.png"] forState:UIControlStateNormal];
    [self.playButton addTarget:self action:@selector(play:) forControlEvents:UIControlEventTouchUpInside];
    [self.playButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.VideoView);
    }];
    
    self.headImageView.frame = CGRectMake(8, VIEW_HEIGHT * 5 / 6 + 20, VIEW_WIDTH / 10, VIEW_WIDTH / 10);
    self.headImageView.layer.cornerRadius = VIEW_WIDTH / 20;
    self.headImageView.layer.masksToBounds = YES;
    
    self.nameTitleLabel.frame = CGRectMake(8 + VIEW_WIDTH / 10, VIEW_HEIGHT * 5 / 6 + 20, VIEW_WIDTH / 2, VIEW_WIDTH / 10 - 15);
    
    self.briefTitleLabel.frame = CGRectMake(8 + VIEW_WIDTH / 10, VIEW_HEIGHT * 5 / 6 + 10 + VIEW_WIDTH / 10, VIEW_WIDTH * 2 / 3, 15);
    self.briefTitleLabel.font = [UIFont systemFontOfSize:13];
    
    self.hotLabel.frame = CGRectMake(VIEW_WIDTH * 2 / 3, VIEW_HEIGHT * 5 / 6 + 18, VIEW_WIDTH * 3 / 10, 15);
    self.hotLabel.font = [UIFont systemFontOfSize:13];
    
}

- (void)setChannel:(AGLChannel *)channel {
    if (_channel != channel) {
        _channel = channel;
    }
    
    NSString *picURL = [NSString stringWithFormat:@"%@%@", self.channel.picbase, self.channel.picm];
    [self.picImageView setImageWithURL:[NSURL URLWithString:picURL]];
    
    NSString *headUrl = [NSString stringWithFormat:@"%@", self.channel.icon];
    [self.headImageView setImageWithURL:[NSURL URLWithString:headUrl]];
  
    self.nameTitleLabel.text = self.channel.nick;
    
    self.briefTitleLabel.text = self.channel.t;
    self.hotLabel.text = [NSString stringWithFormat:@"%@热度", self.channel.vcntNice];
    
    
}

- (void)play:(BaseButton *)sender {
    if (self.playBlock) {
        self.playBlock(sender);
    }
    self.playButton.hidden = YES;
}



@end
